#include "miner.h"
#include <cctype>
Miner::Miner(FacilityDefine *define, FacilityDirection f_dir, Coordinate coordinate,Cargo_Manager *cargo_manager,char target):
    Facility(define,f_dir,coordinate,cargo_manager),
    target(target)
{

}

void Miner::finishProcess(){
    if(target == '_'){return;}
    Cargo* c = null;
    if(std::isupper(target)){ // 大写是颜色
        c = cargo_manager->generateColorCargoWithHashId(target);
        cargo_manager->paintColorCargo(
            coordinate.x,coordinate.y,abs_exits[0].direction,(ColorCargo*)c);
    }
    else{
        ShapeDefine *shapedefine = new ShapeDefine((ShapeType)target);
        c = cargo_manager->generateShapeCargoWithShapeDefine(shapedefine);
        cargo_manager->paintShapeCargo(
            coordinate.x,coordinate.y,abs_exits[0].direction,(ShapeCargo*)c
            );

    }
    outcargos[0] = c;
    sendCargo();
    Facility::finishProcess();
}


bool Miner::inEmpty(){return target == '_';}
